﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Login.Tools;
using MySql.Data.MySqlClient;

namespace Login.view
{
    public partial class UserLogin : UserControl
    {
        JDBCTool jb;
        GroupBox b1;
        public UserLogin()
        {
            InitializeComponent();
        }
        public UserLogin(GroupBox temp)
        {
            b1 = temp;
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            jb = new JDBCTool();

            String sql_str = "select * from user WHERE usrid = " + textBox1.Text + " AND passwd = '" + textBox2.Text + "'";
            Console.WriteLine(sql_str);


            //通过MySqlCommand的ExecuteReader()方法构造DataReader对象(ExecuteReader()返回一个类型化的DataReader对象，返回的对象可对用于遍历返回的记录)
            MySqlDataReader myreader = jb.getmysqlread(sql_str);
            while (myreader.Read())
            {
                Console.WriteLine(myreader.GetInt32(0) + "," + myreader.GetString(1));
                Console.WriteLine("success");
                b1.Controls.Clear();
                b1.Controls.Add(new UserMain(b1));
                
            }
        }

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {

            
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
